package com.xm9m.web.service.security;

import com.salesmanager.web.utils.ServletUtils;
import com.xm9m.web.service.constants.StatusCode;
import com.xm9m.web.service.internal.util.BuildResponseUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


public class CustomerAuthenticationFailureHandler extends
        SimpleUrlAuthenticationFailureHandler {

    @Override
    public void onAuthenticationFailure(HttpServletRequest request,
                                        HttpServletResponse response, AuthenticationException exception)
            throws IOException, ServletException {

        ServletUtils.responseOutWithJson(response, BuildResponseUtil.buildSimpleResponse(StatusCode.LOGIN_ERROR));
    }
}


